﻿<%
'
' 网站样式，外部可以直接引用
' 要求：共同属性写入底层，这部分只是用于展现
' 函数命名：兼容旧系统,暂时没有统一

'URL加密
Function urlEncode(url)
	url=Trim(url)
	If url="" Then urlEncode="":Exit Function
	url=Replace(url,"/","@i@")
	url=Replace(url,"&","@a@")
	url=Replace(url,"?","@q@")
	url=Replace(url,bbssid,bbssid&"1")'删除会话
	url=Replace(url,"=","@e@")
	urlEncode=url
End Function
'URL解密
Function urlDecode(url)
	url=Trim(url)
	If url="" Then urlDecode="":Exit Function
	url=Replace(url,"@i@","/")
	url=Replace(url,"@a@","&")
	url=Replace(url,"@q@","?")
	url=Replace(url,bbssid,bbssid&"1")'删除会话
	url=Replace(url,"@e@","=")
	urlDecode=url
End Function
'格式化文件大小
Function forFileSize(size)
	If Not ifNum(size) Then size=0
	Select Case true
		Case size<1024
			size=size&" B"
		Case size<1048576
			size=Round((size/1024),2)&" KB"
		Case size<1073741824
			size=Round((size/1024/1024),2)&" MB"
		Case else
			size=Round((size/1024/1024/1024),2)&" GB"
	End Select
	forFileSize=size
End Function
'简单问候语
Function getHello()
	Dim newtime
	newtime=time_time
	If newtime < #06:00:00# And newtime >= #00:30:00# Then
		getHello="凌晨好！"
	ElseIf newtime < #09:00:00# And newtime >= #06:00:00# Then
		getHello="早上好！"
	ElseIf newtime < #11:30:00# And newtime >= #09:00:00# Then
		getHello="上午好！"
	ElseIf newtime < #12:30:00# And newtime >= #11:30:00# Then
		getHello="中午好！"
	ElseIf newtime < #18:00:00# And newtime >= #12:30:00# Then
		getHello="下午好！"
	ElseIf newtime < #20:00:00# And newtime >= #18:00:00# Then
		getHello="傍晚好！"
	ElseIf newtime < #23:30:00# And newtime >= #20:00:00# Then
		getHello="晚上好！"
	Else
		getHello="午夜好！"
	End If
End Function
'完整问候语
Function getfavor()
	Dim newtime,newmon,newday
	newtime = time_time:newmon = month(time_now):newday = day(time_now)
	If newtime < #06:00:00# And newtime >= #04:00:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"凌晨好！"
	ElseIf newtime < #09:00:00# And newtime >= #06:00:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"早上好！"
	ElseIf newtime < #11:30:00# And newtime >= #09:00:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"上午好！"
	ElseIf newtime < #12:30:00# And newtime >= #11:30:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"午饭时间到啦。"
	ElseIf newtime < #18:00:00# And newtime >= #12:30:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"下午好！"
	ElseIf newtime < #19:30:00# And newtime >= #18:00:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"晚饭时间到啦。"
	ElseIf newtime < #23:30:00# And newtime >= #19:30:00# Then
		getfavor=""&newmon&"月"&newday&"日"&" "&"晚上好！"
	Else
		getfavor=""&newmon&"月"&newday&"日"&" "&"夜深注意休息。"
	End If
End Function
'统一时间 2008.8.8 20:08
Function fordate(str)
	fordate=hu_dateFormat(str,"y.m.d h:i")
End Function
'统一时间 8-8 20:08
Function fordate2(str)
	fordate2=hu_dateFormat(str,"m-d h:i")
End Function
'时间比较
Function getDiff(day,str)
	Dim newday
	newday = hu_dateDiff(day,"d")
	If newday="" Or IsNumeric(newday)=False Then Exit Function
	If newday>0 Then
		getDiff = "距" & str & "还有" & newday & "天"
	Elseif newday=0 Then
		getDiff = "今天是"& str
	Else
		getDiff = str & "已过了" & newday*-1 & "天"
	End If
End Function
'计算岁数
Function getAge(day)
	Dim newday
	newday = hu_dateDiff(day,"yyyy")
	If Not IsNumeric(newday) Then Exit Function
	getAge = newday*-1
End Function
'检测网站升级
Function checkUpdate
	If adminupdate>0 Then
		Dim tmp_
		If adminupdate > 24 Then
			tmp_ = Int(adminupdate / 24) &"天"
		Else
			tmp_ = adminupdate &"小时"
		End If
		If hu_style Then
			getHead "<title>网站升级</title><body>很抱歉，网站升级中，预计"&tmp_&"后恢复，请稍后再访问..</body><html>",2
		Else
			getHead "</head><card title='网站升级'><p>很抱歉，网站升级中，预计"&tmp_&"后恢复，请稍后再访问..</p></card></wml>",1
		End If
		Response.End
	End If
End Function
'会员签名 显示控制 (信息过滤,同时方便以后vip支持ubb)
Function getRemark(str)
	str=Trim(str)
	If hu_isNull(str) Then
		getRemark="这家伙很懒,什么都没留下"
	Else
		getRemark=noubb(str)
	End If
End Function
'判断性别
Function getSex(sex)
	If IsNumeric(sex) = False Then getSex = "保密":Exit Function
	Select Case sex
		Case 0:getSex="保密"
		Case 1:getSex="男"
		Case 2:getSex="女"
	End Select
End Function
'判断性别
Function getBbsSex(sex)
	If IsNumeric(sex) = False Then getBbsSex = "保密":Exit Function
	Select Case sex
		Case 0:getBbsSex="保密"
		Case 1:getBbsSex="帅哥"
		Case 2:getBbsSex="美女"
	End Select
End Function
'搜索框
Function getSearchXml
	If hu_style Then
		getSearchXml="<form name=""index"" method=""post"" action="""&http_path&"search.asp"">"&_
		"<input type=""text"" name=""keyword"" title=""请输入关键词""/>"&_
		"<br/><select name=""a""><option value=""0"">文章</option><option value=""1"">帖子</option></select>"&_
		"<input type=""hidden"" name="""&bbssid&""" value="""&sid&"""/>"&_
		"<input type=""hidden"" name=""sear"" value=""0""/>&nbsp;<input type=""submit"" value=""搜索""/></form>"&_
		"&nbsp;<a href="""&http_path&"search.asp?"&a_sid&""">更多»</a>"
	Else
		getSearchXml="<input type=""text"" name=""keyword"" value="""" title=""请输入关键词""/><br/>"&_
		"搜<anchor>文章<go href="""&http_path&"search.asp?"&a_sid&""" method=""post""><postfield name=""keyword"" value=""$(keyword)""/>"&_
		"<postfield name=""sear"" value=""0""/></go></anchor>"&_
		".<anchor>帖子<go href="""&http_path&"search.asp?"&a_sid&"&amp;a=1"" method=""post""><postfield name=""keyword"" value=""$(keyword)""/>"&_
		"<postfield name=""sear"" value=""0""/></go></anchor>"&_
		".<anchor>网页<go href=""http://u.yicha.cn/union/x.jsp"" method=""post""><postfield name=""keyword"" value=""$(keyword)""/>"&_
		"<postfield name=""site"" value=""2145930044""/><postfield name=""p"" value=""p""/></go></anchor>"&_
		".<a href="""&http_path&"search.asp?"&a_sid&""">»</a>"
	End If
End Function
'群聊框
Function getWorldCommentXml
	If hu_style Then
		getWorldCommentXml="<form name=""dis"" action="""&http_path&"comment.asp"" method=""post"">"&_
			"<input type=""text"" name=""pl"" value="""" maxlength=""100"" style=""width:110px""/>"&_
			"<input type=""hidden"" name=""id"" value=""0""/><input type=""hidden"" name="""&bbssid&""" value="""&sid&"""/>"&_
			"<input type=""submit"" value=""提交""/></form>"
	Else
		getWorldCommentXml="<input type=""text"" name=""pl"&Time_r&""" title=""输入内容"" value="""" maxlength=""100"" size=""16""/>"&_
		"<anchor title=""确定"">提交<go method=""post"" href="""&http_path&"comment.asp?id=0&amp;"&a_sid&""">"&_
		"<postfield name=""pl"" value=""$(pl"&Time_r&")""/></go></anchor>"
	End If
End Function
'检测是否登录
Sub checkLogin
	If Not iflogin Then
		rupt "页面出错","您还没有以会员身份登陆！<br/><a href="""&http_path&"bbs_login.asp?_u="&back_url&""">现在登录</a> <a href="""&http_path&"bbs_reg.asp?_u="&back_url&""">还没注册？</a>"
	End If
End Sub
'检测是否有新信息
Sub checkMsg
	Dim usrid,msgcount_,usrday
	if wapreport=1 And aid<>"report" then w showImg("board")&""&getReport
	usrid=userArr(0)
	If usrid >0 Then
		usrday=userArr(3)
		If usrday<>"" And bbsbirthday<>"" Then
			If Month(usrday)=Month(time_now) And Day(usrday)=Day(time_now) Then w showImg("birth")&ubbcode(bbsbirthday) &"<br/>"
		End If
		msgcount_=getUserMsgCount(usrid)
		If msgcount_>0 Then w showImg("msg")&"<a href="""&http_path&"bbs_msgs.asp?"&a_sid&""">你有("&msgcount_&")条新信息</a><br/>":Exit Sub
		'以后检测广播,逐渐淘汰公告模式
		msgcount_=getUserFriendApplyCount(usrid)
		If msgcount_>0 Then w showImg("ring")&"<a href="""&http_path&"bbs_friend.asp?"&a_sid&"&amp;a=1"">你有("&msgcount_&")条好友请求</a><br/>":Exit Sub
		If waplogin=1 Then
			If waplogined<>"" Then w ubbcode(waplogined)&"<br/>"
			Exit Sub
		End If
		'会员中心-游戏中心
	Else
		If waplogin=1 Then w "<a href="""&http_path&"bbs_login.asp?_u="&back_url&""">现在登录</a> <a href="""&http_path&"bbs_reg.asp?_u="&back_url&""">还没注册？</a><br/>":Exit Sub
	End If
End Sub
'双引号替换,用途:配置文件无法解析双引号
Function forQuote(str)
	str=Replace(str,"""","'")
	str=Replace(str,"<"&"%","")
	str=Replace(str,"%"&">","")
	str=Replace(str,"	","")
	str=Replace(str,Chr(13),"")
	str=Replace(str,Chr(10),"")
	forQuote=Trim(str)
End Function
'去除广告网址
Function noad(str)
	Set re=new RegExp
	re.IgnoreCase =True
	re.Global=True
	re.Pattern="([0-9A-Za-z- ]+\.)+[A-Za-z ]{2,}"
	str=re.Replace(str,"***.**")
	Set re=Nothing
	noad=str
End Function
'标题和不使用ubb的内容nowml,后台编辑
Function nowml(str)
	If hu_isNull(str) Then Exit Function
	str=Trim(str)
	str=hu_forShow(str)
	nowml=str
End Function
'标题和不使用ubb的内容noubb,前台显示
Function noubb(str)
	If hu_isNull(str) Then Exit Function
	str=Trim(str)
	str=hu_forShow(str)
	str=changeWord(str)
	str=Replace(str,""," ")
	str=Replace(str,"&nbsp;"," ")
	noubb=str
End Function
'用于链接
Function noubburl(str)
	If hu_isNull(str) Then Exit Function
	str=Trim(str)
	str=hu_decode(str)
	str=changeWord(str)
	str=Replace(str,"&","&amp;")
	str=Replace(str,"&amp;amp;","&amp;")'勿删
	str=Replace(str,"<","")
	str=Replace(str,">","")
	str=Replace(str,"'","")
	str=Replace(str,"""","")
	str=Replace(str,"","")
	str=Replace(str,"&nbsp;","")
	str=Replace(str,"&#35;","#")
	str=Replace(str,"&#58;",":")
	str=Replace(str,"&#61;","=")
	str=Replace(str,"&#63;","?")
	str=Replace(str,"%","")
	noubburl=str
End Function
'用于链接
Function nourl(str)
	If hu_isNull(str) Then Exit Function
	str=Trim(str)
	str=hu_decode(str)
	str=changeWord(str)
	str=Replace(str,"&amp;","&")'勿删
	str=Replace(str,"&amp;","&")
	str=Replace(str,"<","")
	str=Replace(str,">","")
	str=Replace(str,"'","")
	str=Replace(str,"""","")
	str=Replace(str,"","")
	str=Replace(str,"&nbsp;","")
	str=Replace(str,"&#35;","#")
	str=Replace(str,"&#58;",":")
	str=Replace(str,"&#61;","=")
	str=Replace(str,"&#63;","?")
	str=Replace(str,"%","")
	nourl=str
End Function
'wml展示
Function wmlcode(str)
	If hu_isNull(str) Then Exit Function
	str=Replace(str,"[sid]",a_sid,1,-1,1)
	Set re=new RegExp
	re.IgnoreCase =True
	re.Global=True
	If InStr(str, "[/wap")>0 Then
		re.Pattern="\[wap1\](.[^\[]*)\[\/wap1\]"
		If hu_style Then
			str=re.Replace(str,"")
		Else
			str=re.Replace(str,"$1")
		End If
		re.Pattern="\[wap2\](.[^\[]*)\[\/wap2\]"
		If hu_style Then
			str=re.Replace(str,"$1")
		Else
			str=re.Replace(str,"")
		End If
	End If
	Set re=Nothing
	wmlcode=str
End Function
'ubb展示
Function ubbcode(str)
	If hu_isNull(str) Then Exit Function
	Dim newstr,re,ma,m,strReg,strExp
	newstr=time_now
	str=Trim(str)
	str=hu_forShow(str)
	str=changeWord(str)
	str=Replace(str,"\\","<br/>")
	str=Replace(str,"&nbsp;"," ")
	str=Replace(str,"[br]","<br/>")
	If InStr(str, "]")>0 Then
		If hu_style Then
			str=Replace(str,"[gotop]","<a href=""#top""><img src=""images/top.gif"" alt=""top""/></a>")
		Else
			str=Replace(str,"[gotop]","")
		End If
		str=Replace(str,"[tab]","&nbsp;")
		str=Replace(str,"[date]",time_date)
		str=Replace(str,"[time]",time_time)
		str=Replace(str,"[now]",newstr)
		str=Replace(str,"[week]",WeekDayName(DatePart("w",newstr)))'星期几
		str=Replace(str,"[month]",Month(newstr))
		str=Replace(str,"[day]",Day(newstr))
		str=Replace(str,"[hello]",gethello)
		str=Replace(str,"[favor]",getfavor)
		str=Replace(str,"[wapname]",waptitle)
		str=Replace(str,"[wapurl]",wapurl)
		str=Replace(str,"[sid]",a_sid)
		str=Replace(str,"[username]",userArr(1))
		'str=Replace(str,"[userid]",userArr(0))
		If InStr(str, "[login]")>0 Then
			If userArr(0)>0 Then
				str=Replace(str,"[login]","<a href='"&http_path&"bbs_user.asp?"&a_sid&"'>会员中心</a>")
			Else
				newstr=back_url
				str=Replace(str,"[login]","<a href="""&http_path&"bbs_login.asp?_u="&newstr&""">登录</a>/<a href="""&http_path&"bbs_reg.asp?_u="&newstr&""">注册</a>")
			End If
		End If
		If InStr(str, "[url_")>0 Then
			str=Replace(str,"[url_report]",http_path&"report.asp?"&a_sid)'与UI对应
			str=Replace(str,"[url_index]",http_path&"?aid=index&amp;"&a_sid)
			str=Replace(str,"[url_list]",http_path&"list.asp?"&a_sid)
			str=Replace(str,"[url_class]",http_path&"class.asp?"&a_sid)
			str=Replace(str,"[url_link]",http_path&"link.asp?"&a_sid)
			str=Replace(str,"[url_art]",http_path&"article.asp?"&a_sid)
			str=Replace(str,"[url_guest]",http_path&"guest.asp?"&a_sid)
			str=Replace(str,"[url_map]",http_path&"map.asp?"&a_sid)
			str=Replace(str,"[url_bookmark]",http_path&"bookmark.asp?"&a_sid)
			str=Replace(str,"[url_new]",http_path&"new.asp?"&a_sid)
			str=Replace(str,"[url_style]",http_path&"style.asp?_u="&back_url&"&amp;"&a_sid)
			str=Replace(str,"[url_topic]",http_path&"bbs_topic.asp?"&a_sid)
			str=Replace(str,"[url_user]",http_path&"bbs_user.asp?"&a_sid)
			str=Replace(str,"[url_msgs]",http_path&"bbs_msgs.asp?"&a_sid)
			str=Replace(str,"[url_posts]",http_path&"bbs_posts.asp?"&a_sid)
			str=Replace(str,"[url_replys]",http_path&"bbs_replys.asp?"&a_sid)
			str=Replace(str,"[url_essay]",http_path&"bbs_essay.asp?"&a_sid)
			str=Replace(str,"[url_mypost]",http_path&"bbs_mypost.asp?"&a_sid)
			str=Replace(str,"[url_myessay]",http_path&"bbs_myessay.asp?"&a_sid)
			str=Replace(str,"[url_online]",http_path&"bbs_online.asp?"&a_sid)
			str=Replace(str,"[url_discuss]",http_path&"discuss.asp?"&a_sid)
			str=Replace(str,"[url_search]",http_path&"search.asp?"&a_sid)
			str=Replace(str,"[url_friend]",http_path&"bbs_friend.asp?"&a_sid)
		End If
		newstr=0
		Set re=new RegExp
		re.IgnoreCase =True
		re.Global=True
		str=Replace(str,"(","→↑↓←_hu_")
		str=Replace(str,")","→↓↑←_hu_")
		If InStr(str, "[/img]")>0 Then
			re.Pattern="\[img\](.[^\[]*)\[\/img\]"
			str=re.Replace(str,"<img src='$1' alt='.'/>")
			re.Pattern="\[img=(.[^\]]*)\](.[^\[]*)\[\/img\]"
			str=re.Replace(str,"<a href='$2'><img src='$1' alt='.'/></a>")
		End If
		If InStr(str, "[/u]")>0 Then
			re.Pattern="\[u\](.[^\[]*)\[\/u\]"
			str=re.Replace(str,"<u>$1</u>")
		End If
		If InStr(str, "[/i]")>0 Then
			re.Pattern="\[i\](.[^\[]*)\[\/i\]"
			str=re.Replace(str,"<i>$1</i>")
		End If
		If InStr(str, "[/b]")>0 Then
			re.Pattern="\[b\](.[^\[]*)\[\/b\]"
			str=re.Replace(str,"<b>$1</b>")
		End If
		If InStr(str, "[/day]")>0 Then
			re.Pattern="\[day=(.[^\]]*)\](.[^\[]*)\[\/day\]"
			str=re.Replace(str,"Diff(""$1"",""$2"")")
			newstr=newstr+1
		End If
		If InStr(str, "[/color]")>0 Then
			re.Pattern="\[color=(.[^\]]*)\](.[^\[]*)\[\/color\]"
			str=re.Replace(str,"<font color=""$1"">$2</font>")
		End If
		If InStr(str, "[/bgsound]")>0 Then
			re.Pattern="\[bgsound](.[^\[]*)\[\/bgsound\]"
			str=re.Replace(str,"<bgsound src='$1' loop='-1' volume='50'/>")
		End If
		If InStr(str, "[/url]")>0 Then
			re.Pattern="\[url\](.[^\[]*)\[\/url\]"
			str=re.Replace(str,"<a href='$1'>$1</a>")
			re.Pattern="\[url=(.[^\]]*)\](.[^\[]*)\[\/url\]"
			str=re.Replace(str,"<a href='$1'>$2</a>")
		End If
		If InStr(str, "[link")>0 Then
			re.Pattern="\[link([^\]]*)\]"
			str=re.Replace(str,"Link(""$1"")")
			newstr=newstr+1
		End If
		If InStr(str, "[online")>0 Then
			re.Pattern="\[online([^\]]*)\]"
			str=re.Replace(str,"Online(""$1"")")
			newstr=newstr+1
		End If
		If InStr(str, "[/m")>0 Then
			re.Pattern="\[m1\](.[^\[]*)\[\/m1\]"
			str=re.Replace(str,"<marquee>$1</marquee>")
			re.Pattern="\[m2\](.[^\[]*)\[\/m2\]"
			str=re.Replace(str,"<marquee behavior=""alternate"" scrollamount=""2"">$1</marquee>")
		End If
		If InStr(str, "[/rnd]")>0 Then
			re.Pattern="\[rnd\](.[^\[]*)\[\/rnd\]"
			str=re.Replace(str,"RndStr(""$1"",""|"")")
			re.Pattern="\[rnd=(.[^\]]*)\](.[^\[]*)\[\/rnd\]"
			str=re.Replace(str,"RndStr(""$2"",""$1"")")
			newstr=newstr+1
		End If
		If InStr(str, "[/center]")>0 Then
			re.Pattern="\[center\](.[^\[]*)\[\/center\]"
			str=re.Replace(str,"<p align='center'>$1</p>")
		End If
		If InStr(str, "[/nav]")>0 Then
			re.Pattern="\[nav\](.[^\[]*)\[\/nav\]"
			str=re.Replace(str,"[div=nav]$1[/div]")
		End If
		If InStr(str, "[/div]")>0 Then
			re.Pattern="\[div=(.[^\]]*)\](.[^\[]*)\[\/div\]"
			If hu_style Then
				str=re.Replace(str,"<div class=""$1"">$2</div>")
			Else
				str=re.Replace(str,"$2<br/>")
			End If
		End If
		If InStr(str, "[/wap")>0 Then
			re.Pattern="\[wap1\](.[^\[]*)\[\/wap1\]"
			If hu_style Then
				str=re.Replace(str,"")
			Else
				str=re.Replace(str,"$1")
			End If
			re.Pattern="\[wap2\](.[^\[]*)\[\/wap2\]"
			If hu_style Then
				str=re.Replace(str,"$1")
			Else
				str=re.Replace(str,"")
			End If
		End If
		If newstr>0 Then
			re.Pattern="(Diff|RndStr|Link|Online)\(.[^\)]*\)"
			Set ma=re.Execute(str)
			For Each m In ma
			strReg=m.Value
			Execute("strExp=get"&strReg)
			str=Replace(str,strReg,strExp)
			Next
			Set ma=Nothing
		End If
		str=Replace(str,"→↑↓←_hu_","(")
		str=Replace(str,"→↓↑←_hu_",")")
		Set re=Nothing
	End If
	ubbcode=str
End Function
'论坛ubb展示
Function bbsubb(str)
	If hu_isNull(str) Then Exit Function
	Dim newstr,re
	newstr=time_now
	str=Trim(str)
	str=hu_forShow(str)
	str=changeWord(str)
	str=Replace(str,"&nbsp;"," ")
	str=Replace(str,"\\","<br/>")
	str=Replace(str,"[br]","<br/>")
	str=Replace(str,"[sid]",a_sid)
	str=Replace(str,"[username]",userArr(1))
	'str=Replace(str,"[userid]",userArr(0))
	Set re=new RegExp
	re.IgnoreCase=True
	re.Global=True
	re.Pattern="\[img\](.[^\[]*)\[\/img\]"
	str=re.Replace(str,"<img src='$1' alt='.'/>")
	re.Pattern="\[img=(.[^\]]*)\](.[^\[]*)\[\/img\]"
	str=re.Replace(str,"<a href='"&http_path&"bbs_urls.asp?url=$2'><img src='$1' alt='.'/></a>")
	re.Pattern="\[u\](.[^\[]*)\[\/u\]"
	str=re.Replace(str,"<u>$1</u>")
	re.Pattern="\[i\](.[^\[]*)\[\/i\]"
	str=re.Replace(str,"<i>$1</i>")
	re.Pattern="\[b\](.[^\[]*)\[\/b\]"
	str=re.Replace(str,"<b>$1</b>")
	re.Pattern="\[color=(.[^\]]*)\](.[^\[]*)\[\/color\]"
	str=re.Replace(str,"<font color=""$1"">$2</font>")
	re.Pattern="\[url\](.[^\[]*)\[\/url\]"
	str=re.Replace(str,"<a href='"&http_path&"bbs_urls.asp?url=$1'>$1</a>")
	re.Pattern="\[url=(.[^\]]*)\](.[^\[]*)\[\/url\]"
	str=re.Replace(str,"<a href='"&http_path&"bbs_urls.asp?url=$1'>$2</a>")
	Set re=Nothing
	bbsubb=str
End Function
'网页头部
Sub getHead(str, ver)
	Select Case ver
	Case 1
		Response.ContentType = "text/vnd.wap.wml; charset=utf-8"
		w "<?xml version=""1.0"" encoding=""utf-8""?>" &_
			"<!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML 1.1//EN"" ""http://www.wapforum.org/DTD/wml_1.1.xml"">" &_
			"<wml><head>" & str
	Case 2
		Response.ContentType = "text/html; charset=utf-8"
		w "<?xml version=""1.0"" encoding=""utf-8""?>" &_
			"<!DOCTYPE html PUBLIC ""-//WAPFORUM//DTD XHTML Mobile 1.0//EN"" ""http://www.wapforum.org/DTD/xhtml-mobile10.dtd"">" &_
			"<html xmlns=""http://www.w3.org/1999/xhtml""><head>" &_
			"<meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8""/>" & str
	Case 0
		Response.ContentType = "text/html; charset=utf-8"
		w "<?xml version=""1.0"" encoding=""utf-8""?>" &_
			"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">" &_
			"<html xmlns=""http://www.w3.org/1999/xhtml""><head>" &_
			"<meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8""/>"& str
	End Select
End Sub
'网页尾部
Sub getEnd(str, ver)
	time_start=FormatNumber((timer-time_start), 3, true)
	Select Case ver
	Case 1
		w str & "<!-- 74hujz "&sysver&" exec "&time_start&"s --></p></card></wml>"
	Case 2,0
		w str & "<!-- 74hujz "&sysver&" exec "&time_start&"s --></div></body></html>"
	End Select
	Response.End
End Sub
'网页内容
Sub getBody(str, ver)
	' On Error Resume Next
	Err.Clear
	Dim f_:f_="show"
	If ver<>1 Then f_=f_&"s"
	Execute f_&str
	If Err.Number<>0 Then Execute f_&"Index":Err.Clear
End Sub
'网页标题
Sub getTitle(str, ver)
	Select Case ver
	Case 1
		w "<card title=""" & str & """><p align=""" & wapconst & """>"
	Case 2,0
		w "<title>" & str & "</title></head><body><div class=""main"">"
	End Select
End Sub
' wap1.0翻页菜单
Function showPage(aim, obj, current, count)
	Dim tmpUrl
	aim = http_path & aim
	If obj="" Then
		tmpUrl = aim &"?" & bbssid & "=" & sid
	Else
		tmpUrl = aim &"?"& Replace(Replace(obj,",","&amp;"),":","=") &"&amp;"&bbssid&"="&sid
	End If
	If current >1 Then showPage = "<a href="""&tmpUrl&"&amp;page=1"">首页</a> "
	If current < count Then showPage = showPage & "<a href="""&tmpUrl&"&amp;page="&current+1&""">下页</a> "
	If current >1 Then showPage = showPage & "<a href="""&tmpUrl&"&amp;page="&current-1&""">上页</a> "
	If current < count Then showPage = showPage & "<a href="""&tmpUrl&"&amp;page="&count&""">末页</a>"
	If count >1 Then showPage = showPage & "(<b>"&current&"</b>/"&count&")<br/>第<input name=""i"&time_r&""" type=""text"" format=""*N"" "&_
		"emptyok=""true"" size=""2"" value="""" maxlength=""2""/>页<anchor> 翻页<go href="""&tmpUrl&""" accept-charset=""utf-8"">"&_
		"<postfield name=""page"" value=""$(i"&time_r&")""/></go></anchor><br/>"
End Function
' wap2.0翻页菜单
Function showsPage(aim, obj, current, count)
	Dim tmpUrl,tmpMenu,paramsArr,paramArr,i,j
	aim = http_path & aim
	If obj="" Then
		tmpUrl = aim &"?" & bbssid &"="& sid &"&amp;"
		tmpMenu = tmpMenu & "<input type=""hidden"" name="""&bbssid&""" value="""&sid&"""/>"
	Else
		paramsArr = Split(obj,",")
		For i=LBound(paramsArr) To UBound(paramsArr)
			paramArr = Split(paramsArr(i),":")
			tmpUrl = tmpUrl & paramArr(0) & "=" & paramArr(1) & "&amp;"
			tmpMenu = tmpMenu & "<input type=""hidden"" name="""&paramArr(0)&""" value="""&paramArr(1)&"""/>"
		Next
		tmpUrl = aim &"?"& tmpUrl & bbssid &"="&sid &"&amp;"
		tmpMenu = tmpMenu & "<input type=""hidden"" name="""&bbssid&""" value="""&sid&"""/>"
	End If
	If current >1 Then showsPage = "<a href="""&tmpUrl&"page=1"">首页</a> "
	If current < count Then showsPage = showsPage & "<a href="""&tmpUrl&"page="&current+1&""">下页</a> "
	If current >1 Then showsPage = showsPage & "<a href="""&tmpUrl&"page="&current-1&""">上页</a> "
	If current < count Then showsPage = showsPage & "<a href="""&tmpUrl&"page="&count&""">末页</a>"
	If count >1 Then showsPage = showsPage & "(<b>"&current&"</b>/"&count&")<br/><form name=""page"" action="""&aim&""" method=""get"">"&_
		"第<input name=""page"" style=""width:25px"" maxlength=""2""/>页" & tmpMenu & " <input type=""submit"" value=""翻页""/></form><br/>"
End Function
'页面展现
Sub draw(str)
	'On Error Resume Next:Err.Clear
	Dim style_,ver_
	If hu_style Then
		ver_ = 2
		'后台生成css样式的文件，直接读取，效率较高
		style_ = "<meta http-equiv=""Cache-control"" content=""max-age=0"" />"&_
		  "<meta http-equiv=""Cache-control"" content=""no-cache""/>"&_
		  "<meta name=""viewport"" content=""width=device-width; initial-scale=1.3;  minimum-scale=1.0; maximum-scale=2.0""/>"&_
		  "<meta name=""MobileOptimized"" content=""240""/>"&_
		  "<meta name=""format-detection"" content=""telephone=no""/>"&_
		  "<style type=""text/css"">"& cssstyle & "</style>"
	Else
		ver_ = 1
		style_ = "<meta http-equiv=""Cache-Control"" content=""no-cache""/><meta http-equiv=""Cache-Control"" content=""max-age=0""/></head>"
	End If
	getHead style_,ver_
	getBody str,ver_
	getEnd "<br/>"&ubbcode(waplast),ver_
End Sub
'中断输出
Sub rupt(title,content)
	'On Error Resume Next:Err.Clear
	Dim ver_,content_
	If hu_style Then
		ver_ = 2
		content_ = "<title>" & title & "</title></head><body><div class=""main"">"&content
	Else
		ver_ = 1
		content_ = "<card title='" & title & "'><p align='"&wapconst&"'>"&content
	End If
	response.write content_
	getEnd "<br/>"&ubbcode(waplast),ver_
End Sub
' 构造链接
Function getUrl(src, name)
	getUrl = hu_anchor(src, name, "", "")
End Function
' 构造图片
Function getImg(src, name)
	getImg = hu_image(src, name, "", "")
End Function

%>